<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>内容过滤选择器的应用</title>
    <meta http-equiv="content-type" content="text/html" charset="utf-8"/>
        <style type="text/css">
 div,span,p {
    width:140px;
    height:140px;
    margin:5px;
    background:#aaa;
	border:#000 1px solid;
    float:left;
    font-size:17px;
    font-family:Verdana;
  }
  div.mini { 
    width:55px;
    height:55px;
    background-color: #aaa;
    font-size:12px;
  }
  div.hide { 
    display:none;
  }
</style>
 <script type="text/javascript" src="jquery-1.8.0.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //1.选取含有文本"di"的div元素
            $("#btn1").click(function () {
                $("div:contains('di')").css("background", "red");
            });

            //2.选取不包含子元素(或者文本元素)的div空元素
            $("#btn2").click(function () {
                $("div:empty").css("background","yellow");
            });

            //3.选取含有class为mini元素 的div元素.
            $("#btn3").click(function () {
                $("div:has(.mini)").css("background", "green");
            });

            //4.选取含有子元素(或者文本元素)的div元素
            $("#btn4").click(function () {
                $("div:parent").css("background", "#bfd");
            });
        });
    </script>
</head>
<body>
  <h3>内容过滤选择器.</h3>
 <input type="button" value="选取含有文本'di'的div元素." id="btn1"/>
  <input type="button" value="选取不包含子元素(或者文本元素)的div空元素." id="btn2"/>
  <input type="button" value="选取含有class为mini元素 的div元素." id="btn3"/>
  <input type="button" value="选取含有子元素(或者文本元素)的div元素." id="btn4"/>
<br /><br />
 
   <!-- 测试的元素 -->
  <div class="one" id="one" >
 id为one,class为one的div
      <div class="mini">class为mini</div>
  </div>
 
    <div class="one"  id="two" title="test" >
	 id为two,class为one,title为test的div.
      <div class="mini"  title="other">class为mini,title为other</div>
      <div class="mini"  title="test" style="position:relative; top:0px; right:1px;">class为mini,title为test</div>
  </div>
 
  <div class="one">
      <div class="mini">class为mini</div>
      <div class="mini">class为mini</div>
	  <div class="mini">class为mini</div>
	  <div class="mini"></div>
  </div>
 
  
 
  <div class="one">
      <div class="mini">class为mini</div>
      <div class="mini">class为mini</div>
	  <div class="mini">class为mini</div>
	  <div class="mini"  title="tesst">class为mini,title为tesst</div>
  </div>
 
 
  <div style="display:none;"  class="none">style的display为"none"的div</div>
  
  <div class="hide">class为"hide"的div</div>
 
  <div>
  包含input的type为"hidden"的div<input type="hidden" size="8"/>
  </div>
 
  
  <span id="mover">正在执行动画的span元素.</span>
 
</body>

</html>


